package com.musketeers.tiktok.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.musketeers.common.annotation.Log;
import com.musketeers.common.core.controller.BaseController;
import com.musketeers.common.core.domain.AjaxResult;
import com.musketeers.common.enums.BusinessType;
import com.musketeers.tiktok.domain.TiktokNumber;
import com.musketeers.tiktok.service.ITiktokNumberService;
import com.musketeers.common.utils.poi.ExcelUtil;
import com.musketeers.common.core.page.TableDataInfo;

/**
 * 我的抖音Controller
 * 
 * @author musketeers
 * @date 2023-12-27
 */
@RestController
@RequestMapping("/tiktok/number")
public class TiktokNumberController extends BaseController
{
    @Autowired
    private ITiktokNumberService tiktokNumberService;

    /**
     * 查询我的抖音列表
     */
    @PreAuthorize("@ss.hasPermi('tiktok:number:list')")
    @GetMapping("/list")
    public TableDataInfo list(TiktokNumber tiktokNumber)
    {
        startPage();
        List<TiktokNumber> list = tiktokNumberService.selectTiktokNumberList(tiktokNumber);
        return getDataTable(list);
    }

    /**
     * 导出我的抖音列表
     */
    @PreAuthorize("@ss.hasPermi('tiktok:number:export')")
    @Log(title = "我的抖音", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TiktokNumber tiktokNumber)
    {
        List<TiktokNumber> list = tiktokNumberService.selectTiktokNumberList(tiktokNumber);
        ExcelUtil<TiktokNumber> util = new ExcelUtil<TiktokNumber>(TiktokNumber.class);
        util.exportExcel(response, list, "我的抖音数据");
    }

    /**
     * 获取我的抖音详细信息
     */
    @PreAuthorize("@ss.hasPermi('tiktok:number:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tiktokNumberService.selectTiktokNumberById(id));
    }

    /**
     * 新增我的抖音
     */
    @PreAuthorize("@ss.hasPermi('tiktok:number:add')")
    @Log(title = "我的抖音", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TiktokNumber tiktokNumber)
    {
        return toAjax(tiktokNumberService.insertTiktokNumber(tiktokNumber));
    }

    /**
     * 修改我的抖音
     */
    @PreAuthorize("@ss.hasPermi('tiktok:number:edit')")
    @Log(title = "我的抖音", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TiktokNumber tiktokNumber)
    {
        return toAjax(tiktokNumberService.updateTiktokNumber(tiktokNumber));
    }

    /**
     * 删除我的抖音
     */
    @PreAuthorize("@ss.hasPermi('tiktok:number:remove')")
    @Log(title = "我的抖音", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tiktokNumberService.deleteTiktokNumberByIds(ids));
    }
}
